package com.web.handler.entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

import org.springframework.format.annotation.DateTimeFormat;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.ser.std.SerializableSerializer;
import com.web.common.ReturnCode;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.ToString;

@ToString
@ApiModel
public class QuotePrice implements Serializable {

	private static final long serialVersionUID = 1L;

	public static String QUOTEPRICE_STATUS_NORMAL = "NOR";
	public static String QUOTEPRICE_STATUS_CANCEL = "CAN";

	public static DateTimeFormatter yyyyMMdd = DateTimeFormatter.ofPattern("yyyyMMdd");

	@ApiModelProperty("quotePriceNo")
	private String quotePriceNo;
	@ApiModelProperty("status")
	private String status;
	@ApiModelProperty("customerNo")
	private String customerNo;
	@DateTimeFormat(pattern = "yyyy-MM-dd")
	@JsonFormat(shape = JsonFormat.Shape.STRING, pattern="yyyy-MM-dd")
	@ApiModelProperty("tradedate")
	private LocalDate tradeDate;
	@ApiModelProperty("accountNo1")
	private String accountNo1;
	@ApiModelProperty("currency1")
	private String currency1;
	@ApiModelProperty("amount1")
	private BigDecimal amount1;
	@ApiModelProperty("accountNo2")
	private String accountNo2;
	@ApiModelProperty("currency2")
	private String currency2;
	@ApiModelProperty("amount2")
	private BigDecimal amount2;
	@ApiModelProperty("buySellOption")
	private String buySellOption;
	@ApiModelProperty("bankCostRate")
	private BigDecimal bankCostRate;
	@ApiModelProperty("returnCode")
	private String returnCode = ReturnCode.OK;
	@ApiModelProperty("returnMsg")
	private String returnMsg;

	public String getReturnCode() {
		return returnCode;
	}
	public void setReturnCode(String returnCode) {
		this.returnCode = returnCode;
	}
	public String getReturnMsg() {
		return returnMsg;
	}
	public void setReturnMsg(String returnMsg) {
		this.returnMsg = returnMsg;
	}
	public LocalDate getTradeDate() {
		return tradeDate;
	}
	public void setTradeDate(LocalDate tradeDate) {
		this.tradeDate = tradeDate;
	}
	public String getCustomerNo() {
		return customerNo;
	}
	public void setCustomerNo(String customerNo) {
		this.customerNo = customerNo;
	}
	public String getAccountNo1() {
		return accountNo1;
	}
	public void setAccountNo1(String accountNo1) {
		this.accountNo1 = accountNo1;
	}
	public String getCurrency1() {
		return currency1;
	}
	public void setCurrency1(String currency1) {
		this.currency1 = currency1;
	}
	public BigDecimal getAmount1() {
		return amount1;
	}
	public void setAmount1(BigDecimal amount1) {
		this.amount1 = amount1;
	}
	public String getAccountNo2() {
		return accountNo2;
	}
	public void setAccountNo2(String accountNo2) {
		this.accountNo2 = accountNo2;
	}
	public String getCurrency2() {
		return currency2;
	}
	public void setCurrency2(String currency2) {
		this.currency2 = currency2;
	}
	public BigDecimal getAmount2() {
		return amount2;
	}
	public void setAmount2(BigDecimal amount2) {
		this.amount2 = amount2;
	}
	public BigDecimal getBankCostRate() {
		return bankCostRate;
	}
	public void setBankCostRate(BigDecimal bankCostRate) {
		this.bankCostRate = bankCostRate;
	}
	public String getBuySellOption() {
		return buySellOption;
	}
	public void setBuySelloption(String buySellOption) {
		this.buySellOption = buySellOption;
	}
	public String getStatus() {
		return status;
	}

	public void setStatus(String status) {
		this.status = status;
	}

	public String getQuotePriceNo() {
		return quotePriceNo;
	}

	public void setQuotePriceNo(String quotePriceNo) {
		this.quotePriceNo = quotePriceNo;
	}

	public boolean isContainUSD() {
		return getCurrency1().equals("USD") || getCurrency2().equals("USD");
	}

	public boolean isCurrency1USD() {
		return getCurrency1().equals("USD");
	}

	public boolean isCurrency2USD() {
		return getCurrency2().equals("USD");
	}

	public QuotePrice markNew() {
		setStatus(QUOTEPRICE_STATUS_NORMAL);
		return this;
	}
}
